package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Account;

public class CheckingAccount implements Account{

	private int balance;
	private int overdraft = 30;
	
	public CheckingAccount(int balance){
		this.balance = balance;
	}
	
	@Override
	public int getBalance() {
		return balance;
	}

	@Override
	public void deposit(double x) {
		balance += x;
	}

	@Override
	public void withdraw(double x) {
		if(x <= balance)
			balance -= x;
		else
		{
			x -= balance;
			if(x <= overdraft){
				overdraft -= x;
				System.out.println("You received a credit = " + x);
			}
			else
				System.out.println("Value " + (x+balance) + " is more than your balance");
		}
	}

	@Override
	public double maximumAmountToWithdraw() {
		return balance+overdraft;
	}
}
